home *** CD-ROM | disk | FTP | other *** search
- Path: news.IntNet.net!news
- From: vic@intnet.net (Vic Sperry)
- Newsgroups: comp.lang.c++
- Subject: Re: Random numbers
- Date: Thu, 11 Jan 1996 15:51:57 GMT
- Organization: Intelligence Network Online, Inc.
- Message-ID: <4d3c5h$6mu@mercury.IntNet.net>
- References: <4cul2d$gi@news.ran.es>
- NNTP-Posting-Host: pm-clw-5-37.intnet.net
- X-Newsreader: Forte Free Agent 1.0.82
-
- mper@ran.es wrote:
-
- >How many "random" numbers can be created using the rand() function without repitition.
- >I am using this routine for a physics projects which simulates alpha scattering (Rutherford
- >Scattering), and I do about 1 million iterations through the main loop, creating 1 million random numbers.
- >Obviously, if its just repeating the numbers, the whole point of the simulation is gone.
-
- >Anyone who knows, please answer,
-
- >TIA
- >Martin.
-
- Obtaining the answer to this question is far more complicated than you might expect.
- Donald Knuth wrote an excellent chapter on random numbers in "The Art of Computer
- Programming, Volume 2 / Seminumerical Algorithms". All pseudo random number
- generators repeat eventually, but if your compiler vendor used solid theory in
- implementing rand(), it will have a "very large" period (certainly more than 1 million).
- If you must be 100% positive, you could read Knuth and implement your own version
- of rand().
-
-
-
- Vic Sperry
- vic@intnet.net
- Ever had a time-shifted E-mail conversation
- with your spouse who's asleep in the next room?
-
-